package com.tm.servicemsm.controller;

import com.tm.servicemsm.demos.Pump;

import java.util.ArrayList;
import java.util.List;

import static com.tm.servicemsm.demos.Pump.findClosestPump;

/**
 * 2024/7/19 Cjj
 * 订单,以及根据当前位置查找附近售卖机等功能
 */
public class FuelingSuggestion {
    public static void main(String[] args) {
        //假设有一个已知的汽油售卖机列表
       /* ArrayList<Pump> pumps = new ArrayList<>();
        //添加一些示列汽油售卖机
        pumps.add(new Pump(1,"901 High St",37.7833,-122.4167));
        //..添加更多汽油售卖机

        //假设有一个用户位置
        double userLatitude=37.7833;
        double userLongitude=-122.4167;

        //查找离用户最近的汽油售卖机
      Pump closestPump=  findClosestPump(pumps,userLatitude,userLongitude);
      if(closestPump!=null){
          System.out.println("最近的汽油售卖机位于："+closestPump);

      }else {
          System.out.println("没有找到汽油售卖机");
      }
    }

    private static Pump findClosestPump(List<Pump> pumps,double userLongitude){
           if(pumps.isEmpty()){
               return null;
           }
        Pump closest = pumps.get(0);
           distance(closest.latiude,closest.longitde,userLatitude,userLongitude);

        for (Pump pump : pumps) {
            double distance = distance(pump.latitude, pump.longitude, userLatitude, userLongitude);
            if (distance < minDistance) {
                minDistance = distance;
                closest = pump;
            }
        }
        return closest;*/
    }
}

